﻿using System;
using Newtonsoft.Json;
using OrkutAPILibrary.Enums;

namespace OrkutAPILibrary.Entities
{
    /// <summary>
    /// Orkut Birthday Notification Class
    /// </summary>
    public class OrkutBirthdayNotification
    {
        internal string _birthDay;
        internal string _type;
        internal string _fromUserId;
        internal OrkutPerson _fromUserProfile;

        /// <summary>
        /// Gets or sets the birth month.
        /// </summary>
        /// <value>The birth month.</value>
        public Months BirthMonth { get; internal set; }

        
        [JsonProperty(PropertyName = "birthMonth")]
        internal string _birthMonth
        {
            get { return _birthMonth; }
            set
            {
                BirthMonth = (Months)Convert.ToInt32(value);
            }
        }

        /// <summary>
        /// Gets or sets the birth day.
        /// </summary>
        /// <value>The birth day.</value>
        [JsonProperty(PropertyName = "birthDay")]
        public string BirthDay
        {
            get { return _birthDay; }
            internal set { _birthDay = value; }
        }

        /// <summary>
        /// Gets or sets the type.
        /// </summary>
        /// <value>The type.</value>
        [JsonProperty(PropertyName = "type")]
        public string Type
        {
            get { return _type; }
            internal set { _type = value; }
        }

        /// <summary>
        /// Gets or sets from user id.
        /// </summary>
        /// <value>From user id.</value>
        [JsonProperty(PropertyName = "fromUserId")]
        public string FromUserId
        {
            get { return _fromUserId; }
            internal set { _fromUserId = value; }
        }

        internal static readonly DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);

        public DateTime Time { get; internal set; }

        /// <summary>
        /// Gets or sets the time.
        /// </summary>
        /// <value>The time.</value>
        [JsonProperty(PropertyName = "time")]
        internal string _time
        {
            get
            {
                return (Time - unixEpoch).TotalSeconds.ToString();
            }
            set
            {
                Time = unixEpoch.AddSeconds(Convert.ToInt32(value));
            }
        }

        /// <summary>
        /// Gets or sets from user profile.
        /// </summary>
        /// <value>From user profile.</value>
        [JsonProperty(PropertyName = "fromUserProfile")]
        public OrkutPerson FromUserProfile
        {
            get { return _fromUserProfile; }
            internal set { _fromUserProfile = value; }
        }
    }
}
